<template>
  <div class="songList">
    <h1>歌单推荐</h1>

    <el-carousel trigger="click" height="260px" :autoplay="false" indicator-position="outside">
      <el-carousel-item>
        <el-row :gutter="20">
          <el-col :span="4" v-for="item in hotSongList1" :key="item.id">
            <img :src="item.picUrl" alt="error" @click="toSongListDetails(item.id)">
            <div class="listName" :title="item.name" @click="toSongListDetails(item.id)">{{item.name}}</div>
            <div class="pbCount">播放量：{{formatNumber(item.playCount)}}</div>
          </el-col>
        </el-row>
      </el-carousel-item>
      <el-carousel-item>
        <el-row>
          <el-col :span="4" v-for="item in hotSongList2" :key="item.id">
            <img :src="item.picUrl" alt="error" @click="toSongListDetails(item.id)">
            <div class="listName" :title="item.name" @click="toSongListDetails(item.id)">{{item.name}}</div>
            <div class="pbCount">播放量：{{formatNumber(item.playCount)}}</div>
          </el-col>
        </el-row>
      </el-carousel-item>
      <el-carousel-item>
        <el-row>
          <el-col :span="4" v-for="item in hotSongList3" :key="item.id">
            <img :src="item.picUrl" alt="error" @click="toSongListDetails(item.id)">
            <div class="listName" :title="item.name" @click="toSongListDetails(item.id)">{{item.name}}</div>
            <div class="pbCount">播放量：{{formatNumber(item.playCount)}}</div>
          </el-col>
        </el-row>
      </el-carousel-item>
    </el-carousel>
  </div>
</template>

<script scoped>
export default {
  name: "HotSongList",
  props: ["hotSongList1", "hotSongList2", "hotSongList3"],
  methods: {
    toSongListDetails(id) {
      this.$router.push({ name: "SongListDetail", params: { id: id } });
    },
    formatNumber(num) {
      num = Number(num);
      if (num == 0) {
        return num + '';
      } else
        if (num > 1 && num < 10000) {
          return num + '';
        } else {
          return (num / 10000).toFixed(1) + '万';
        }
    }
  }
}
</script>

<style scoped>
img {
  width: 90%;
  height: 90%;
}
.listName {
  font-size: 1rem;
  width: 100%;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
  cursor: pointer;
}
.listName:hover {
  color: RGB(64, 158, 255);
}
.pbCount {
  font-size: 1rem;
  width: 100%;
  color: RGB(153, 153, 153);
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
  cursor: pointer;
}
.songList {
  background: -webkit-linear-gradient(
    top,
    RGB(246, 246, 246),
    RGB(255, 255, 255)
  );
}
.songList h1 {
  text-align: center;
  padding-top: 30px;
}
.el-carousel {
  margin-left: 20px;
}
.el-row {
  margin-bottom: 20px;
}
.el-col {
  border-radius: 4px;
}
.row-bg {
  padding: 10px 0;
  background-color: #f9fafc;
}
.el-carousel__item:nth-child(2n) {
  background: -webkit-linear-gradient(
    top,
    RGB(246, 246, 246),
    RGB(255, 255, 255)
  );
}

.el-carousel__item:nth-child(2n + 1) {
  background: -webkit-linear-gradient(
    top,
    RGB(246, 246, 246),
    RGB(255, 255, 255)
  );
}
</style>